//#pragma once

#ifndef __VECTOR_H__
#define __VECTOR_H__

#include <iostream>
#include <cassert>
using namespace std;

namespace yyp
{
	template<class T>
	class vector
	{
	public:
		typedef T value_type;
		typedef T* iterator;
		typedef const T* const_iterator;

		/*struct iterator
		{
			iterator begin()
			{
				return _start;
			}

			const iterator begin() const 
			{
				return _start;
			}

			iterator end()
			{
				return _finish;
			}

			const iterator end() const
			{
				return _finish;
			}
		};*/

	public:
		vector() = default;
		vector(size_t n, const T& val = T())
		{
			_start = new T[n];
			for (size_t i = 0; i < n; ++i)
			{
				_start[i] = val;
			}

			_finish = _start + n;
			_end_of_storage = _finish;
		}

		vector(const vector& v)
		{
			_start = new T[v.size()];

			size_t sz = v.size();
			for (size_t i = 0; i < sz; ++i)
			{
				_start[i] = v[i];
			}

			_finish = _start + sz;
			_end_of_storage = _finish;
		}

		~vector()
		{
			delete[] _start;

			_start = _finish = _end_of_storage = nullptr;
		}

		size_t size() const
		{
			return _finish - _start;
		}

		size_t capacity() const
		{
			return _end_of_storage - _start;
		}

		bool empty() const
		{
			return _start == _finish;
		}

		T& operator[](size_t n)
		{
			assert(n < size());

			return *(_start + n);
		}

		const T& operator[](size_t n) const
		{
			assert(n < size());

			return *(_start + n);
		}


	private:
		T* _start = nullptr;
		T* _finish = nullptr;
		T* _end_of_storage = nullptr;
	};












}



#endif
